﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GrayParrot.Core.Data;

namespace GrayParrot.Data.EntityFramework
{
    public abstract class FacadeBase<T> : IFacadeBase, IFacadeEntityFrameWork, IDisposable where T : class, new()
    {
        //IDbContext m_context = null;

        public FacadeBase()
        {

        }

        public static T Create()
        {
            T retValue = new T();

            ((IFacadeBase)retValue).Initialize();

            return retValue;
        }

        public static T Create(DbContext context)
        {
            T retValue = new T();

            ((IFacadeEntityFrameWork)retValue).Initialize(context);

            return retValue;
        }

        public abstract void Initialize();
        public abstract void Initialize(DbContext context);

        public abstract void Dispose();
    }
}
